<section id="content">
<form id="main_form" method="post">
	<script type="text/javascript">
		function func_edit(id){
			$("#hidId").val(id);
			$("#main_form").prop("action", "edit");
			return $("#main_form").submit();
		}
		
		function func_delete(id){
			var r=confirm("Bạn muốn xóa khóa học này?")
			if (r==true){
				$("#hidId").val(id);
				$("#main_form").prop("action", "delete");
				return $("#main_form").submit();
			}else{
				return;
			}
		}
		
		
	</script>
	<input type="hidden" name="id" id="hidId" value="" /> 
	<div id="main_div">

		<center>
			<H1>Quản Lí Khóa Học</H1>
		</center>
		<br/>
		<div id="regist">
			<a href="add" class="regist" >Thêm mới khóa học</a>
		</div>
		<br/>
		<table id="main_table">
			<tr>
				<th width="100">Tên khóa học</th>
				<th width="450">Mô tả về khóa học</th>
				<th></th>
			</tr>
			<?php foreach ($courses as $course): ?>
			<tr>
				<td><?php echo $course['Course']['m_course_name']; ?>
				</td>
				<td>
					<?php if(strlen($course['Course']['m_course_descript']) > 50){?>
					<?php echo substr(html_entity_decode($course['Course']['m_course_descript'], ENT_QUOTES, 'utf-8'), 0, 70). "..."; ?>
					<?php }else{?>
					<?php echo html_entity_decode($course['Course']['m_course_descript'], ENT_QUOTES, 'utf-8'); ?>
					<?php }?>
				</td>
				<td width="150">
					<a class="edit" href="#" onclick="func_edit(<?php echo $course['Course']['m_course_id']; ?>)">Cập nhật</a>
					<a class="delete" href="#" onclick="func_delete(<?php echo $course['Course']['m_course_id']; ?>)">Xóa</a>				
				</td>
			</tr>
			<?php endforeach; ?>
			<?php unset($courses); ?>
		</table>
	</div>
</form>
</section>
